import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-02-08
 * Time: 19:09
 */
public class Test {

    public static void main(String[] args) {
        //二维数组
        //1.
        int[][] array1 = new int[2][3];//默认是0
        int[][] array2 = new int[][] {{1,2,3},{4,5,6}};//初始化了
        int[][] array3 = {{1,2,3},{4,5,6}};//初始化了

        //打印二维数组
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 3; j++) {
                System.out.print(array2[i][j]+" ");
            }
            System.out.println();
        }
//        System.out.println(Arrays.toString(array2));//错误的,输出地址
        System.out.println(Arrays.deepToString(array2));//正确的
        System.out.println(array2[0]);//二维数组0下标输出的是地址
        System.out.println(array2[1]);//二维数组0下标输出的是地址
        for (int i = 0; i < array2.length; i++) {
            for (int j = 0; j < array2[i].length; j++) {
                System.out.print(array2[i][j]+" ");
            }
            System.out.println();
        }

        for(int[] arr:array2) {
            for(int x:arr) {
                System.out.print(x+" ");
            }
            System.out.println();
        }

    }

    public static void main1(String[] args) {
        //冒泡排序
        int[] arr = {2, 3, 1, 4, 7, 5, 8, 6, 9,};
        System.out.println(Arrays.toString(arr));
        for (int i = 0; i < arr.length - 1; i++) {

            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    int tmp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = tmp;
                }
            }
        }

        System.out.println(Arrays.toString(arr));

    }
}
